<template>
    <uni-popup ref="activityPopupRef" @change="onPopupChange" :safe-area="false">
        <view class="activity-popup-goods">
            <view class="title">
                <text></text>
                <text>活动详情</text>
                <text @click="onPopupChange({ show: false })" class="detail-img-close">×</text>
            </view>
            <view class="content">
                <view class="label">活动内容：</view>
                <view class="right">
                    单笔订单活动商品金额<text class="red-color">{{ state.activityDesc }}</text>
                </view>
            </view>
            <view class="content">
                <view class="label">活动时间：</view>
                <view class="right">{{ state.activityStartTime }} ~ {{ state.activityEndTime }}</view>
            </view>
            <view class="content">
                <view class="label">其他说明：</view>
                <view class="right">
                    <text>{{ state.discountRepeat === 1 ? '不可' : '可' }}同时使用优惠券</text>
                    <text v-if="state.fullReduceMail !== 1">；包邮</text>
                </view>
            </view>
            <view class="footer" :style="{ paddingBottom: safeArea ? 0 : '30rpx' }">
                <view class="btn" @click="onConfirm">查看详情</view>
            </view>
        </view>
    </uni-popup>
</template>

<script setup>
import store from '@/store';
import router from '@/router';
import { computed, ref, watch } from 'vue';

const props = defineProps({
    modelValue: { type: Boolean, default: false },
    data: { type: Object, default: () => ({}) }
});
const emit = defineEmits(['update:modelValue']);

const safeArea = store.useTabBarStore().safeArea;
const activityPopupRef = ref(null);
const state = computed(() => props.data);

const onConfirm = () => {
    emit('update:modelValue', false);
    router.push({
        path: '/pages-cart/activeDetail/index',
        query: {
            activityId: state.value.data.activity.id
        }
    });
};
// 打开/关闭弹窗
const onPopupChange = e => {
    emit('update:modelValue', e.show);
};
watch(
    () => props.modelValue,
    v => {
        if (v) {
            activityPopupRef.value.open('bottom');
        } else {
            activityPopupRef.value.close();
        }
    }
);
</script>

<style lang="scss" scoped>
.activity-popup-goods {
    width: 100%;
    padding-bottom: constant(safe-area-inset-bottom);
    padding-bottom: env(safe-area-inset-bottom);
    border-radius: 22rpx 22rpx 0rpx 0rpx;
    color: #333333;
    background-color: #ffffff;

    font-family: PingFangSC-Regular, PingFang SC;
    font-size: 25rpx;
    .title {
        display: flex;
        justify-content: space-between;

        margin-bottom: 54rpx;
        padding-top: 19rpx;

        text-align: center;

        color: #333333;

        font-family: PingFangSC-Medium, PingFang SC;
        font-size: 31rpx;
        font-weight: 500;
        line-height: 43rpx;
    }
    .detail-img-close {
        width: 29rpx;
        height: 29rpx;
        padding-right: 29rpx;

        color: #cccccc;

        font-size: 40rpx;
    }
    .content {
        display: flex;

        margin-bottom: 22rpx;
        padding: 0 65rpx 0 29rpx;
        .label {
            width: 126rpx;
        }
        .right {
            flex: 1;
            .red-color {
                color: #fe292b;
            }
        }
    }
    .footer {
        .btn {
            height: 80rpx;
            margin: 120rpx 29rpx 0 29rpx;

            text-align: center;

            color: #ffffff;
            border-radius: 40rpx;
            background: linear-gradient(270deg, #ff5356 0%, #fe292b 100%);

            font-size: 29rpx;
            font-weight: 500;
            line-height: 80rpx;
        }
    }
}
</style>
